﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="temp_TryNicWYSIWYG" Codebehind="TryNicWYSIWYG.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css"
        type="text/css" media="all" />
    <link href="../Styles/StyleSheet.css" rel="stylesheet" type="text/css" />
    <link href="../Styles/start/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
    

    <script src="../Scripts/jquery-1.7.js" type="text/javascript"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.core.js"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.position.js"></script>
    <script type="text/javascript" src="../Scripts/ui/jquery.ui.autocomplete.js"></script>
      
     

<body>
    <form id="form1" runat="server">
    <div>
    
      <script type="text/javascript">
          var tempString;
          $(function () {
              $("#<%= TextBox1.ClientID %>").autocomplete({
                  source: function (request, response) {
                      $.getJSON("AutoComplete.ashx", {
                          term: extractLast(request.term);
                          }
                      }, response);
                  },
                  search: function () {
                      // custom minLength 
                      var term = extractLast(this.value);
                      if (term.length < 1) {
                          return false;
                      }
                  },
                  focus: function () {
                      // prevent value inserted on focus 
                      return false;
                  },
                  select: function (event, ui) {

                      var terms = split(this.value);

                      // remove the current input 
                      terms.pop();
                      // add the selected item 
                      //terms.push(ui.item.value); --original
                      //alert("*" + ui.item.TextAbreviere + "*");
                      terms.push(ui.item.Abreviere);
                      // add placeholder to get the comma-and-space at the end 
                      terms.push("");
                      this.value = terms.join("");

                      $get('<%= TextBox1.ClientID %>').value = ui.item.TextAbreviere;
                      return false;
                  }
              })
            .data("autocomplete")._renderItem = function (ul, item) {
                return $("<li></li>")
				.data("item.autocomplete", item)
				.append("<a>" + item.Abreviere + " : " + item.TextAbreviere + " [" + item.Specialitate + "]" + "</a>")
				.appendTo(ul);
            };
              function split(val) {
                  return val.split(/ \s*/);
              }
              function extractLast(term) {
                  return split(term).pop();
              }
          }); 
    </script>


    </div>
    <asp:TextBox ID="TextBox1" runat="server" Height="262px" Width="731px"></asp:TextBox>
    </form>
</body>
</html>
